package dataconnect;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * description: SqlConnection
 * sql连接主类
 * 
 * @author what-is-me
 * @date 2022/1/3 23:24
 */
public class SqlConnection {
    public Password password;
    public Investment inv;
    Connection connection = null;
    Statement st;

    public void init() throws SQLException {
        /**
         * Description: init
         * 
         * @param :
         * @return
         * @throws
         * @author what-is-me
         * @date 2022/1/3 23:25
         */
        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/investment?useSSL=false", "guest",
                "password");
        if (connection != null) {
            System.out.print("We have connected to our database!\r");
            st = connection.createStatement();
            password = new Password(st);
            inv = new Investment(st);
        }
    }
}